package tp.pr5.mv.instructions.stack;

import tp.pr5.mv.Instruction;
import tp.pr5.mv.Memory;
import tp.pr5.mv.Opcode;
import tp.pr5.mv.OperandStack;
import tp.pr5.mv.ProgramCounter;
import tp.pr5.mv.inout.InMethod;
import tp.pr5.mv.inout.OutMethod;
import tp.pr5.mv.traps.MVTrap;
import tp.pr5.mv.traps.WithoutOperandsEx;


public class POP extends Instruction {
	
	
	public POP() { // Constructor por defecto
		
		op = Opcode.POP;
		
	}
	

	public void execute ( OperandStack stack, Memory mem, ProgramCounter pc, InMethod inMethod, OutMethod outMethod) throws MVTrap {
		
		if ( stack.isEmpty() )    // Necesitamos al menos un operando en la pila.
			throw new WithoutOperandsEx( this, stack.getCounter() );
		
		
		stack.pop();
		
	}
	
}
